package com.bridgeintelligent.tag.webserver.dim.mgmt.api.export;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.wayneleo.quickstart.framework.BaseException;
import com.wayneleo.quickstart.framework.ExceptionCode;

public class DepartmentConverter implements Converter<String> {
     @Override
    public Class<String> supportJavaTypeKey() {
        return String.class;
    }

    @Override
    public CellDataTypeEnum supportExcelTypeKey() {
        return CellDataTypeEnum.STRING;
    }

    @Override
    public String convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration)
            throws Exception {
        if (cellData.getType().equals(CellDataTypeEnum.NUMBER)) {
            return String.valueOf(cellData.getNumberValue().intValue());
        } else if (cellData.getType().equals(CellDataTypeEnum.STRING)) {
            return cellData.getStringValue();
        } else {
            throw new BaseException( new ExceptionCode(999, "部门ID转换失败:" + cellData.getStringValue() ) );
        }
    }

}
